<template>
  <div id="app">
    <tabbar></tabbar>
    <transition name="myswithch" mode="out-in">
      <!-- keep-alive用来缓存，防止用户·疯狂切换 -->
      <keep-alive>
        <router-view id="root" ref="root" />
      </keep-alive>
      
    </transition>
    
  </div>
</template>

<script>
import tabbar from "@/components/Tabbar.vue";
import {bus,EVENT_SCRLL_END} from '@/helper/bus_helper.js'
export default {
  components: {
    tabbar,
  },
  mounted() {
    const appThis = this;
    window.onscroll = function () {
      if (
        document.documentElement.scrollTop >=
        (appThis.$refs.root.$el.offsetHeight + 40) - window.innerHeight
      ) {
        console.log("滚动见地了");
        // 
        bus.$emit(EVENT_SCRLL_END,null)
      }
    };
  },
  beforeDestroy(){
    window.onscroll =null;
  }
};
</script>

<style lang="scss">
// 组件切换效果
.myswithch-leave-to,.myswithch-enter{
  opacity: 0;
  transform: translateY(2rem);
}
.myswithch-leave-active,.myswithch-enter-active{
  transition: all .2s;
}


// 静态效果
* {
  margin: 0;
  padding: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  #root {
    margin-bottom: 40px;
  }
}
.film-detail{
  text-align: left;
}
.film-name{
  .item{
    width: 15px;
  }
}
</style>
